#ifndef UART_H
#define UART_H

#include <QObject>
#include <QTimer>
#include <QDateTime>
#include <QElapsedTimer>
#include <QDebug>
#include <QHash>
#include "BasePort.h"
#include "System/qextserialport.h"

class UART : public BasePort
{
    Q_OBJECT

public:
    Q_INVOKABLE UART(QObject *parent = 0);
    ~UART();

    void setPortParam(PortStruct portParam);
    void open();
    void close();
    void write(PortStruct target,QByteArray data);



private:
    QextSerialPort *uart;
    QTimer *readTimer;
    QByteArray m_readData;
    quint8 m_readCount;

    bool m_isSetEnablePin;
    QHash<QString,QextSerialBase::QueryMode> m_modeHash;
    QHash<QString,BaudRateType> m_baudRateHash;
    QHash<QString,DataBitsType> m_dataBitsHash;
    QHash<QString,ParityType>   m_parityHash;
    QHash<QString,StopBitsType> m_stopBitsHash;
    QHash<QString,FlowType>     m_flowControlHash;


private slots:
    void readyReadSlot();
};

#endif // RS485_H
